'use strict';
app.service('modulesAdvertisementService',['$q','utilService',function($q,utilService){
    var _this_=this;

    //上下架
    this.changeStatus = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'advertise/change/status',
            data:{id:$scope.advertise.id},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }


    //置顶
    this.toTop = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'advertise/toTop',
            data:{id:$scope.advertise.id},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    //删除模块广告
    this.del = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + '/modules/advertise/del',
            data:{modulesAdvertiseId:$scope.modulesAdvertise.modulesAdvertiseId},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

}]);